import os
import shutil
import zipfile

# 远程目录路径
# remote_path = r'\\diskstation3\10T_02\FitGirl20240502'
remote_path = r'F:\迅雷下载\___games'

# 获取远程目录下的文件列表
file_list = os.listdir(remote_path)

# 遍历文件列表
for file_name in file_list:
    # 构建文件的绝对路径
    file_path = os.path.join(remote_path, file_name)
    if os.path.isdir(file_path):
        print(f"processing {file_name}")
        inner_file_list = os.listdir(file_path)
        for inner_file_name in inner_file_list:
            inner_file_path = os.path.join(file_path, inner_file_name)
            # 检查文件是否是.exe文件
            if os.path.isfile(inner_file_path) and inner_file_name.endswith('setup.exe'):
                # 创建压缩文件名
                zip_file_name = os.path.splitext(inner_file_name)[0] + '.zip'
                # 构建压缩文件的绝对路径
                zip_file_path = os.path.join(file_path, zip_file_name)
                # 压缩文件
                with zipfile.ZipFile(zip_file_path, 'w') as zipf:
                    zipf.write(inner_file_path, arcname=os.path.basename(inner_file_path))

print("压缩完成")
